package com.xuanzheng.company.entity;

import java.sql.Date;
import java.sql.Timestamp;

/**
 * AI使用限制实体类
 */
public class AIUsageLimit {
    private String id;
    private String userId;
    private int dailyLimit;
    private int usedToday;
    private Date lastResetDate;
    private Timestamp createTime;
    private Timestamp updateTime;

    public AIUsageLimit() {}

    public AIUsageLimit(String id, String userId, int dailyLimit, int usedToday, Date lastResetDate) {
        this.id = id;
        this.userId = userId;
        this.dailyLimit = dailyLimit;
        this.usedToday = usedToday;
        this.lastResetDate = lastResetDate;
    }

    // Getters and Setters
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public int getDailyLimit() {
        return dailyLimit;
    }

    public void setDailyLimit(int dailyLimit) {
        this.dailyLimit = dailyLimit;
    }

    public int getUsedToday() {
        return usedToday;
    }

    public void setUsedToday(int usedToday) {
        this.usedToday = usedToday;
    }

    public Date getLastResetDate() {
        return lastResetDate;
    }

    public void setLastResetDate(Date lastResetDate) {
        this.lastResetDate = lastResetDate;
    }

    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }

    /**
     * 获取剩余提问次数
     */
    public int getRemainingQuestions() {
        return Math.max(0, dailyLimit - usedToday);
    }

    /**
     * 检查是否可以提问
     */
    public boolean canAsk() {
        return getRemainingQuestions() > 0;
    }

    @Override
    public String toString() {
        return "AIUsageLimit{" +
                "id='" + id + '\'' +
                ", userId='" + userId + '\'' +
                ", dailyLimit=" + dailyLimit +
                ", usedToday=" + usedToday +
                ", lastResetDate=" + lastResetDate +
                '}';
    }
}